#ifndef ULTRASONIC_H
#define ULTRASONIC_H

#include <Arduino.h>
#include "motor_car.h"

// 超声波参数
#define MAX_DISTANCE 300
#define SOUND_SPEED 0.034

// 引脚定义
#define ULTRASONIC_TRIG_PIN 5
#define ULTRASONIC_ECHO_PIN 18

class Ultrasonic {
private:
    int TRIG_PIN;
    int ECHO_PIN;

public:
    Ultrasonic(int trigPin, int echoPin);
    float getDistance();
    bool checkObstacle(float threshold = 20.0);
};

#endif